<?php	
require_once(dirname(__FILE__).'/inc/config.inc.php');

IsModelPriv('goodsorder');
$op_uid=$_SESSION['uid'];
//初始化参数
$tbname = '#@__sn';
$gourl  = 'zhengshu.php';
$action = isset($action) ? $action : '';
//引入操作类
require_once(ADMIN_INC.'/action.class.php');
//添加友情链接
if($action == 'add'){
		$beginTime=strtotime($beginTime);
		$endTime=strtotime($endTime);
		$input_time = GetMkTime($input_time);
	
	
	if(isset($num)){
		$num=trim($num);
		$num_arr = explode(PHP_EOL, $num);
		if(is_array($num_arr)){
			$num_count=count($num_arr);
			$ii=0;
			foreach ($num_arr as $k=>$v){
				$v=trim($v);
				$ii++;
				if(!empty($v)){
						/*==========生成 条形码 开始===============*/
						$value=$cfg_weburl."admin/barcode/html/image.php?filetype=PNG&dpi=72&scale=3&rotation=0&font_family=Arial.ttf&font_size=16&text=".$v."&thickness=30&start=NULL&code=BCGcode128";
						$ch = curl_init();
						//设置选项，包括URL
						curl_setopt($ch, CURLOPT_URL, $value);
						curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
						curl_setopt($ch, CURLOPT_HEADER, 0);
						//执行并获取HTML文档内容
						 curl_exec($ch);
						//释放curl句柄
						curl_close($ch);
						/*==========生成 条形码 结束===============*/
						

						$sql = "INSERT INTO `$tbname` (typeid,typename,sn, school,truename,mobile,address, input_time,start_time,end_time, checkinfo,user) VALUES ('$typeid','$typename', '$v','$school','$truename','$mobile','$address','$input_time', '$beginTime','$endTime','$checkinfo','$op_uid');";
						$dosql->ExecNoneQuery($sql);
						//插入数据结束
				}
			}
			if($ii==$num_count){
				header("location:$gourl");
				exit();
			}
		}

	}
}





//修改友情链接

else if($action == 'update')

{

		  $beginTime=strtotime($beginTime);
		  $endTime=strtotime($endTime);

		/*==========生成 条形码 开始===============*/
		$value=$cfg_weburl."admin/barcode/html/image.php?filetype=PNG&dpi=72&scale=3&rotation=0&font_family=Arial.ttf&font_size=16&text=".$num."&thickness=30&start=NULL&code=BCGcode128";
		$ch = curl_init();
		//设置选项，包括URL
		curl_setopt($ch, CURLOPT_URL, $value);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		//执行并获取HTML文档内容
		 curl_exec($ch);
		//释放curl句柄
		curl_close($ch);
		/*==========生成 条形码 结束===============*/

	$sql = "UPDATE `$tbname` SET  typeid='$typeid', typename='$typename',school='$school',truename='$truename',mobile='$mobile',address='$address', start_time='$beginTime',end_time='$endTime',checkinfo='$checkinfo' WHERE id=$id";
	if($dosql->ExecNoneQuery($sql))
	{
		header("location:$gourl");
		exit();
	}
}





//无条件返回

else
{
    header("location:$gourl");
	exit();
}

?>

